package com.lwx.simpleapplication;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.PopupWindow;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    public void popwindow(View view){

        PopupWindow popupWindow = new PopupWindow();
        DisplayMetrics metrics = new DisplayMetrics();
        getWindowManager().getDefaultDisplay().getMetrics(metrics);
        int width = metrics.widthPixels;
        int height = metrics.heightPixels;

        popupWindow.setWidth(width);
        popupWindow.setHeight(height/2);
        View popView = LayoutInflater.from(this).inflate(R.layout.pop_window,null);
        TextView textView = new TextView(this);
        textView.setText("Test Pop Window");
        popupWindow.setContentView(popView);

        popupWindow.setFocusable(true);
        popupWindow.showAtLocation(popView, Gravity.BOTTOM,0,0);


    }


    private static final String TAG = "MainActivity";
    @Override
    protected void onResume() {
        super.onResume();
        Log.i(TAG, "onResume: ");
    }


    @Override
    protected void onPause() {
        super.onPause();
        Log.i(TAG, "onPause: ");
    }
}
